package demo05173;


import java.util.Map;

public class TestMap {
    public void addEmp(Map<String, Emp> map, Emp emp) {
        map.put(emp.getNumber(), emp);
    }

    public void findAllEmp(Map<String, Emp> map) {
        for (Emp emp : map.values()) {
            System.out.println(emp);
        }
    }

    public Emp findEmpName(Map<String, Emp> map, String name) {
        for (Emp emp : map.values()) {
            if (name.equals(emp.getName())) {
                return emp;
            }
        }
        return null;
    }

    public void deleteEmpNumber(Map<String, Emp> map, String number) {
        map.remove(number);
        System.out.println(map);
    }

    public Emp findEmpNumber(Map<String, Emp> map, String number) {
        return map.get(number);
    }

    public void updateEmpAge(Map<String, Emp> map, Emp emp) {
        map.put(emp.getNumber(), emp);
        System.out.println(map);
    }
}